<template>
    <div id="wrapper" style="height:100%;">
        <!-- top -->
        <div class="sellnage-nav tab fixed-top mt-97 border20-bottom">
            <ul class="tab-nav">
                <li class="fl border-bottom f30" :class="{'active':params.orderstatus == ''}"
                    @click="selectStatus('')">
                    <a class="nav-04">全部</a>
                </li>
                <li class="fl border-bottom f30" :class="{'active':params.orderstatus == '0'}"
                    @click="selectStatus('0')">
                    <a class="nav-03">待付款</a>
                </li>
                <li class="fl border-bottom f30" :class="{'active':params.orderstatus == '1|2'}"
                    @click="selectStatus('1|2')">
                    <a class="nav-01">交易中</a>
                </li>
                <li class="fl border-bottom f30" :class="{'active':params.orderstatus == 3}" @click="selectStatus('3')">
                    <a class="nav-02">交易完成</a>
                </li>
            </ul>
        </div>
        <div class="sellmanage-main mt-205">
            <div class="seller-01 " ref="tab">
                <div class="sellnage-connt mb-20" v-for="v in orderList">
                    <!--M站订单-->
                    <div v-if="v.orderinfo.otradingtype == 7||v.orderinfo.otradingtype == 6||v.orderinfo.otradingtype == 10">
                        <div class="manage-caption px-30  bg-fff">
                            <div class="manage-titl py-30 f28">
                                <!--M站订单需对jsondata转对象-->
                                <span class=" fl mr-30 fontbold">{{getJsondata(v)}}</span>
                                <!-- <i class="manage-titl-ico" v-if="v.goodsType == 2"></i> -->
                            </div>
                            <!--非装备类跳转详情页-->
                            <a @click="goDetail(v)" v-if="v.orderinfo.oordersource != 'M.Equipment'">
                                <div class="manage-contn bg-faf">
                                    <div class="mancon-img fl">
                                        <i class="f22 color-fff bg-000">
                                            <!--订单标题-->
                                            <span v-if="(v.mjsondata&&v.mjsondata.BizOfferTypeName!='null')"></span>
                                            {{v.mjsondata?v.mjsondata.BizOfferTypeName:v.orderinfo.obizoffertypename}}
                                        </i>
                                        <span class="middle"></span>
                                        <img src="../../../../assets/images/default_img.jpg"
                                             v-if="!v.mjsondata">
                                        <img :src="v.mjsondata.PicUrlManager" v-if="v.mjsondata">
                                    </div>
                                    <div class="mancon-tn py-15">
                                        <div class="tn-hxtxt f26 color-666"
                                             v-if="v.orderinfo.oordersource != 'Msy.AppleRecharge'&&v.orderinfo.oordersource != 'M.MobileGameMoney'&&v.orderinfo.oordersource != 'M.GameAccount'&&v.orderinfo.oordersource != 'M.MobileGameAccount'&&v.orderinfo.otradingtype!=6&&v.orderinfo.otradingtype!=10">
                                            <!--非快充类手游充值订单副标题拼接-->
                                            {{v.mjsondata.GameName}} /{{v.mjsondata.PlatformName || v.mjsondata.GameAreaName}} /{{v.mjsondata.PlatformName ? v.mjsondata.GameAreaName : v.mjsondata.GameServerName}}
                                           
                                        </div>
                                        <div class="tn-hxtxt f26 color-666"
                                             v-if="v.orderinfo.oordersource == 'Msy.AppleRecharge'">
                                            <!--快充直接取gamename-->
                                            {{v.mjsondata.GameName}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666"
                                             v-if="(v.orderinfo.otradingtype==6||v.orderinfo.otradingtype==10)&&!v.mjsondata">
                                            <!--金币商城-->
                                             {{v.orderinfo.ogamename}}/{{v.orderinfo.ogamearea}}/{{v.orderinfo.ogameserver}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666"
                                             v-if="(v.orderinfo.otradingtype==6||v.orderinfo.otradingtype==10)&&v.mjsondata">
                                            <!--金币商城游戏币-->
                                             {{v.mjsondata.GameName}}/{{v.mjsondata.GameAreaName}}/{{v.mjsondata.GameServerName}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666"
                                             v-if="v.orderinfo.oordersource == 'M.MobileGameMoney'||v.orderinfo.oordersource == 'M.GameAccount'||v.orderinfo.oordersource == 'M.MobileGameAccount'">
                                            <!--手游金币,账号-->
                                            {{v.mjsondata.GameName}} /{{v.mjsondata.GameAreaName}} /{{v.mjsondata.GameServerName}}
                                        </div>
                                        <!--<div class="tn-hxtxt f26 color-666" v-if="v.mjsondata.SubTitle">-->
                                        <!--{{v.mjsondata.SubTitle}}-->
                                        <!--</div>-->
                                        <div class="tn-hxtxt f26 color-666 "
                                             v-if="v.orderinfo.otradingtype == 10||v.orderinfo.otradingtype == 6">
                                            商品价格：{{v.orderinfo.opayprice}}元
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 " v-if="v.orderinfo.oordersource == 'M.GameMoney'">商品价格：{{v.orderinfo.opayprice}}元
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 " v-if="v.orderinfo.otradingtype != 10&&v.orderinfo.otradingtype != 6&&v.orderinfo.oordersource != 'M.GameMoney'">商品价格：{{v.orderinfo.oprice}}元
                                        </div>
                                        <!--<div class="tn-hxtxt f26 color-666" v-if="params.status != 2">下单时间：{{v.createTime | format}}</div>-->
                                        <div class="tn-hxtxt f26 color-666">下单时间：{{v.orderinfo.oordercreatedate}}</div>
                                    </div>
                                </div>
                            </a>
                            <a v-if="v.orderinfo.oordersource == 'M.Equipment'" @click="goToEquip(v)">
                                <div class="manage-contn bg-faf">
                                    <div class="mancon-img fl">
                                        <i class="f22 color-fff bg-000">
                                          <span v-if="v.mjsondata.BizOfferTypeName!='null'">
                                            {{v.mjsondata.BizOfferTypeName?v.mjsondata.BizOfferTypeName:v.orderinfo.obizoffertypename}}
                                            </span>
                                           
                                        </i>
                                        <span class="middle"></span>
                                        <img src="../../../../assets/images/default_img.jpg"
                                             v-if="!v.mjsondata.PicUrlManager">
                                        <img :src="v.mjsondata.PicUrlManager" v-if="v.mjsondata.PicUrlManager">
                                    </div>
                                    <div class="mancon-tn py-15">
                                        <div class="tn-hxtxt f26 color-666">
                                            {{v.mjsondata.GameName}}/{{v.mjsondata.GameAreaName}}/{{v.mjsondata.GameServerName}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 ">商品价格：{{v.orderinfo.oprice}}元</div>
                                        <div class="tn-hxtxt f26 color-666">下单时间：{{v.orderinfo.oordercreatedate}}</div>
                                    </div>
                                </div>
                            </a>
                        </div>
                        <div class="mancon-titl px-30 py-30 bg-fff border-bottom ">
                            <span class="title-curent f30 pl-30 color-000 buyct-why">{{v.orderstatus.oorderstatusname}}　
                                <!--<em v-if="v.BizOfferTypeId==3 && v.JsonData.sendTime && v.BizOfferTypeId==2 && v.BizOfferTypeId==1" class="f26">预计到账时间：{{initTime(v.JsonData.sendTime + 86700000) }}</em>　-->
                                <!--<i v-if="v.orderstatus.oorderstatusid == 4">退款原因:{{v.mjsondata.CancelReasons}}</i>-->
                            </span>
                        </div>
                        <div class="mancon-btn pr-20 py-20 bg-fff border-bottom">
            <span
                    v-if="v.orderinfo.obizoffertypeId ==3 &&v.orderstatusid == 3"
                    class="kucun pl-30 color-000 f30 fl" style="line-height: .7rem">件数：{{v.mjsondata.num}}<span
                    class="color-m1 fontarial">{{v.orderinfo.oquantity}}</span></span>
                            <a class="f30 color-m1 border border-color cancel fr"
                               v-if="(v.orderinfo.oordersource == 'M.GameAccount'||v.orderinfo.oordersource == 'M.MobileGameMoney'||v.orderinfo.oordersource == 'M.MobileGameAccount')&&v.orderstatus.oorderstatusid!=0" @click="
                getKefu(v)">联系客服</a>
                            <a class="f30 color-m1 border border-color cancel fr"
                               v-if="v.orderinfo.obizoffertypeId == 3 && v.CQTradingType == 3"
                               @click="getKefu(v)">联系客服</a>
                               <a class="f30 color-m1 border border-color cancel fr"
                                v-if="(v.orderinfo.otradingtype == 6 || v.orderinfo.otradingtype == 10)&&v.orderinfo.oshowcontactop === 'true'" 
                               @click="getKefu(v)">联系客服</a>
                            <a class="f30 color-m1 border border-color cancel fr"
                               v-if="v.orderinfo.oordersource == 'Msy.FirstRecharge'||v.orderinfo.oordersource == 'Msy.ReplaceRecharge'||v.orderinfo.oordersource == 'Msy.ContinueRecharge'||v.orderinfo.oordersource == 'Msy.AppleRecharge'"
                               @click="syczGoserver(v)">联系买家</a>
                            <!--<i class="titcur fr" @click="whyClick(v)"-->
                            <!--v-if="v.orderinfo.obizoffertypeId == 3 && v.CQTradingType == 2"></i>-->
                        </div>
                    </div>


                    <!--主站订单-->
                    <div v-if="v.orderinfo.otradingtype != 7&&v.orderinfo.otradingtype != 6&&v.orderinfo.otradingtype != 10">
                        <div class="manage-caption px-30  bg-fff">
                            <div class="manage-titl py-30 f28">
                              
                              <span class=" fl mr-30 fontbold" v-if="v.orderinfo.ojsondata">{{getJsondata(v)}}</span>
                                <span class=" fl mr-30 fontbold" v-if="!v.orderinfo.ojsondata">{{v.orderinfo.otitle}}</span>
                                <!-- <i class="manage-titl-ico" v-if="v.goodsType == 2"></i> -->
                            </div>
                            <a @click="goDetail(v)" v-if="v.orderinfo.obizoffertypename != '装备'">
                                <div class="manage-contn bg-faf">
                                    <div class="mancon-img fl">
                                        <i class="f22 color-fff bg-000" v-if="v.mjsondata">
                                          <span v-if="v.mjsondata.BizOfferTypeName!='null'">
                                            {{v.mjsondata.BizOfferTypeName}}
                                            </span>
                                            
                                        </i>
                                        <i class="f22 color-fff bg-000" v-if="!v.mjsondata">
                                          <span v-if="v.orderinfo.obizoffertypename!='null'">
                                            {{v.orderinfo.obizoffertypename}}
                                            </span>
                                          
                                        </i>
                                        <span class="middle"></span>
                                        <img src="../../../../assets/images/default_img.jpg">
                                        <!--<img :src="v.mjsondata.PicUrlManager" v-if="v.mjsondata.PicUrlManager">-->
                                    </div>
                                    <div class="mancon-tn py-15">
                                        <div class="tn-hxtxt f26 color-666" v-if="v.mjsondata">
                                            {{v.mjsondata.GameName}}/{{v.mjsondata.GameAreaName}}/{{v.mjsondata.GameServerName}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666" v-if="!v.mjsondata&&v.orderinfo.otradingtype!=4">
                                            {{v.orderinfo.ogamename}}/{{v.orderinfo.ogamearea}}/{{v.orderinfo.ogameserver}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666" v-if="v.orderinfo.otradingtype==4">
                                            {{v.orderinfo.ogamename}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 "
                                             v-if="v.orderinfo.oprice">
                                            商品价格：{{v.orderinfo.oprice}}元/件
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 " v-else>商品价格：{{v.orderinfo.opayprice}}元
                                        </div>
                                        <!--<div class="tn-hxtxt f26 color-666" v-if="params.status != 2">下单时间：{{v.createTime | format}}</div>-->
                                        <div class="tn-hxtxt f26 color-666">下单时间：{{v.orderinfo.oordercreatedate}}</div>
                                    </div>
                                </div>
                            </a>
                            <a v-if="v.orderinfo.obizoffertypename == '装备'" @click="goToEquip(v)">
                                <div class="manage-contn bg-faf">
                                    <div class="mancon-img fl">
                                        <i class="f22 color-fff bg-000">
                                          <span v-if="v.orderinfo.obizoffertypename!= 'null'">{{v.orderinfo.obizoffertypename}}</span>
                                            
                                        </i>
                                        <span class="middle"></span>
                                        <img src="../../../../assets/images/default_img.jpg"
                                             v-if="!v.orderinfo.PicUrlManager">
                                        <img :src="v.orderinfo.PicUrlManager" v-if="v.orderinfo.PicUrlManager">
                                    </div>
                                    <div class="mancon-tn py-15">
                                        <div class="tn-hxtxt f26 color-666">
                                            {{v.orderinfo.ogamename}}/{{v.orderinfo.ogamearea}}/{{v.orderinfo.ogameserver}}
                                        </div>
                                        <div class="tn-hxtxt f26 color-666 ">商品价格：{{v.orderinfo.opayprice}}元</div>
                                        <div class="tn-hxtxt f26 color-666">下单时间：{{v.orderinfo.oordercreatedate}}</div>
                                    </div>
                                </div>
                            </a>
                        </div>
                        <div class="mancon-titl px-30 py-30 bg-fff border-bottom ">
                            <span class="title-curent f30 pl-30 color-000 buyct-why">{{v.orderstatus.oorderstatusname}}
                                <em v-if="v.operators">
                                  {{delayPay(v.operators)}}
                                    <!--:{{v.operators[0].do}}-->
                                </em>
                                <!--<em v-if="v.BizOfferTypeId==3 && v.JsonData.sendTime && v.BizOfferTypeId==2 && v.BizOfferTypeId==1" class="f26">预计到账时间：{{initTime(v.JsonData.sendTime + 86700000) }}</em>　-->
                                <!--<i v-if="v.BizOfferTypeId!=4 &&v.orderinfo.mjsondata.complainResult">退款原因:{{v.orderinfo.mjsondata.complainResult | complainResultFilter}}</i>-->
                            </span>
                        </div>
                        <div class="mancon-btn pr-20 py-20 bg-fff border-bottom ">
            <span
                    v-if="v.CQTradingType ==3 &&v.BizOfferTypeId == 3"
                    class="kucun pl-30 color-000 f30 fl" style="line-height: .7rem">件数：<span
                    class="color-m1 fontarial">{{v.orderinfo.oquantity}}</span></span>
                   
                            <a class="f30 color-m1 border border-color cancel fr" v-if="v.orderinfo.oshowcontactop === 'true'&&v.orderinfo.otradingtype!=3"
                               @click="getServiceParams(v)">联系客服</a>
                               <a class="f30 color-m1 border border-color cancel fr" v-if="v.orderinfo.oshowcontactop === 'true'&&v.orderinfo.otradingtype==3"
                               @click="getPcService(v.oid,parseInt(v.orderinfo.otradingtype))">联系客服</a>
                            <!--<a class="f30 color-m1 border border-color cancel fr"-->
                            <!--v-if=" v.obizoffertypename == '游戏币'" @click="goToServe(v)">联系客服</a>-->
                            <!--<i class="titcur fr" @click="whyClick(v)"-->
                            <!--v-if="v.orderinfo.obizoffertypeId == 3 && v.CQTradingType == 2"></i>-->
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="loading" v-show="loading">加载中...</div>
        <div class="list-empty bg-fff" v-show="orderList.length===0 && !loading">
            <p><img src="~images/gamelogo.png"></p>
            <span>您还没有订单</span>
        </div>
    </div>
</template>
<script>
import { mapState, mapGetters, mapActions } from "vuex";
import api from "../../../../api";
import { BuyerCenterApi } from "api/index";
import {
  complainResultFilter,
  cancelReasonFilter
} from "components/common/filters";
import config from "components/im/config";
import cookie from "js/utils/cookie.js";
import SDK from "components/im/sdk/NIM_Web_SDK_v4.0.0.js";

export default {
  data() {
    return {
      url:
        location.protocol +
        "//" +
        location.hostname +
        "/api/mobile-order-service/rs/orderdata/getOrderIm",
      //url: 'http://syt.5173.com/api/mobile-order-service/rs/orderdata/getOrderIm',
      params: {
        //                status: this.$route.query.status,
        orderstatus: this.$route.query.orderstatus,
        tradingtype: "",
        keywords: "",
        pageindex: 1,
        pagesize: 10,
        usertype: 0,
        //                    nomapping:true
        sourcetype: 2
      },
      scrollTop: 0,
      isAysnc: true,
      loading: false,
      orderList: [],
      orderListAllLoad: false,
      jsPath: "http://consignment.5173.com/ajax.axd?methodName=GetOrderIMInfo",
      dbPath: "http://danbao.5173.com/ajax.axd?methodName=GetOrderIMInfo",
      zhPath: "http://gameid.5173.com/BankInfo.axd?methodName=GetOrderIMInfo",
      syPath: "http://sy.5173.com/api/order/getorderim",
      scPath:
        "http://yxbmall.5173.com/gamegold-facade-frontend/services/orderdata/getOrderIm",
      url:
        location.protocol +
        "//" +
        location.hostname +
        "/api/mobile-order-service/rs/orderdata/getOrderIm",
        msgBox:true,
        // url:
        
        // "http://mappeal.5173.com/api/mobile-order-service/rs/orderdata/getOrderIm"
    };
  },
  computed: {},
  watch: {
    async scrollTop(val, oldVal) {
      var vm = this;
      if (vm.$isBottom(200) && !vm.orderListAllLoad&&!vm.loading) {
        ++vm.params.pageindex;
        
         await vm.getList();

        //vm.getOrderMobileList(vm.params);
      }
    }
  },
  created: function() {
    let self = this;
    // if (this.$isLocalStorageSupported()) {
		// 		if(sessionStorage.getItem("msgBox")){
		// 			this.msgBox = sessionStorage.getItem("msgBox")
		// 		}
		// 	}
		// 	if(this.msgBox == true){
		// 	this.$messagebox('卖家订单改版啦~~~游戏币、装备、帐号、手游订单都可以在这里查看啦~~~').then( sessionStorage.setItem("msgBox",false))
	 	// 	}
    self.$bus.emit("headerText", "卖家订单");
    self.$nextTick(() => {
      document.body.scrollTop = self.scrollTop;
      document.documentElement.scrollTop = self.scrollTop;
    });
  },
  beforeMount() {
   
  },
  mounted: function() {
    var vm = this;
    vm.loading = true;
    BuyerCenterApi.getOrderList(vm.params).then(res => {
      vm.orderList = res.data.Data.OrderPages.Orders;
      vm.loading = false;
    });

    vm.watchGoTop();
    vm.$bus.emit("isBack", false);
    vm.$bus.emit("callback", () => {
      vm.$router.push({ name: "MemberSeller" });
    });
    vm.$bus.emit("isMore", true);
    this.setXiaoNeng()
  },
  methods: {
    delayPay(item){
      var str;
      for(var i = 0;i<item.length;i++){
        if(item[i].name == "延迟转账到账时间"){
          str = item[i].name+' '+item[i].do
        }
      }
      return str;
    },
    setXiaoNeng() {
				const s1 = document.createElement('script');
				s1.type = 'text/javascript';
				s1.text = 'NTKF_PARAM = {' +
					'siteid: "bq_1000",' +
					'settingid: "bq_1000_9999",' +
					'uid: "",' +
					'uname: "",' +
					'isvip: "0",' +
					'userlevel: "1",' +
					'erpparam: "abc"' +
					'}';
				document.body.appendChild(s1);
				const s = document.createElement('script');
				s.type = 'text/javascript';
				s.src = encodeURI('https://dl.ntalker.com/js/b2b/ntkfstat.js?siteid=bq_1000');
				s.charset = "utf-8";
				document.body.appendChild(s);
			},
    async getServiceParams(item) {
      var self = this;
      var params = {
        methodName: "GETTRADEORDERIMINFO",
        orderid: item.oid,
        usertype: 0,
        tradingtype: item.orderinfo.otradingtype,
        clienttype: 2
      };
      await BuyerCenterApi.getPcServer(params).then(res => {
        if (res) {
          if (res.serverType == 1) {
            self.getPcService(item.oid, parseInt(item.orderinfo.otradingtype));
          } else if (res.serverType == 2) {
            location.assign(
              "https://sh-v2.ntalker.com/downt/t2d/chat.php?v=2017.08.23&siteid=bq_1000&settingid=" +
                res.params +
                "&baseuri=https%3A%2F%2Fdl.ntalker.com%2Fjs%2Fb2b%2F&mobile=1&ref=https%3A%2F%2Fm.5173.com%2Fvue%2Fmobile-game%2Fgoods-list2%2F76bae5aefec047e89bcb6aa4e417f138%2F%25E7%258E%258B%25E8%2580%2585%25E8%258D%25A3%25E8%2580%2580%2F2&tit=%E7%8E%8B%E8%80%85%E8%8D%A3%E8%80%80&iframechat=0&header=1&rnd=1512371179444"
            );
          } else if (res.serverType == 3) {
            window.location.assign(
              "mqqwpa://im/chat?chat_type=wpa&uin=" +
                res.KefuQQ +
                "&version=1&src_type=web&web_src=oicqzone.com"
            );
          }
        }
      });
    },
    syczGoserver(v) {
      var obj = JSON.parse(v.orderinfo.oremarks);
      location.href = obj.ContactBuyer;
    },
    getJsondata(v) {
      var title = "";
      if (v.orderinfo.ojsondata) {
        var object = JSON.parse(v.orderinfo.ojsondata);
        v.mjsondata = object;

        if (v.mjsondata.SubTitle) {
          title = v.mjsondata.SubTitle;
        } else {
          title = v.mjsondata.BizOfferName;
        }
      } else {
        title = v.orderinfo.otitle;
      }
      return title;
    },

    initTime: function(needTime) {
      //needTime是整数，否则要parseInt转换
      var time = new Date(parseInt(needTime));
      var y = time.getFullYear();
      var m = time.getMonth() + 1;
      var d = time.getDate();
      var h = time.getHours();
      var mm = time.getMinutes();
      var s = time.getSeconds();
      //          return y+'-'+this.add0(m)+'-'+this.add0(d)+' '+this.add0(h)+':'+this.add0(mm)+':'+this.add0(s);
      if (!needTime) {
        return "登陆中";
      } else {
        return (
          this.add0(y) +
          "-" +
          this.add0(m) +
          "-" +
          this.add0(d) +
          " " +
          this.add0(h) +
          ":" +
          this.add0(mm) +
          ":" +
          this.add0(s)
        );
      }
    },
    add0: function(m) {
      return m < 10 ? "0" + m : m;
    },
    
    goDetail(v) {
      this.saveSrollTop();
      if (v.orderinfo.otradingtype == 7) {
        var remark;
        if (v.orderinfo.oremarks) {
          remark = JSON.parse(v.orderinfo.oremarks);
        }
        if (v.orderinfo.obizoffertypeId == 3) {
          if (remark && remark.SubId) {
            this.$router.push({
              name: "OrderMobileDetail",
              query: { orderId: v.oid, Id: remark.SubId }
            });
          } else {
            this.$router.push({
              name: "OrderMobileDetail",
              query: { orderId: v.oid, Id: v.mjsondata.SubId }
            });
          }
        } else if (
          v.orderinfo.oordersource == "Msy.FirstRecharge" ||
          v.orderinfo.oordersource == "Msy.ReplaceRecharge" ||
          v.orderinfo.oordersource == "Msy.ContinueRecharge" ||
          v.orderinfo.oordersource == "Msy.AppleRecharge"
        ) {
          window.location.assign(
            location.origin +
              "/recharge/recharge-shopdetai-shou.html?orderId=" +
              v.oid
          );
        } else {
          if (remark && remark.SubId) {
            if(v.orderinfo.oordersource == 'M.MobileGameMoney'&&v.orderstatus.oorderstatusid!=0){
              this.$router.push({
              name: "OrderMobileCoinDetail",
              query: { orderId: v.oid, Id: remark.SubId }
            });
            }else if(v.orderstatus.oorderstatusid!=0){
              this.$router.push({
              name: "OrderMobileDetail",
              query: { orderId: v.oid, Id: remark.SubId }
            });
            }else{
              return
            }
            
          } else {
            this.$router.push({
              name: "OrderMobileDetail",
              query: { orderId: v.oid, Id: v.mjsondata.SubId }
            });
          }
        }
      } else {
        
        if (
          v.orderinfo.otradingtype == 3 &&
          v.orderinfo.oordersource == "Sy.GameAccount"
        ) {
          this.$router.push({
            name: "OrderPCDetail",
            query: { orderId: v.oid }
          });
        } else if(v.orderinfo.otradingtype == 5){
         this.$router.push({
              name: "OederPcDetail",
              query: { orderId: v.oid}
            });
        }else if (v.orderinfo.otradingtype == 3 &&
          v.orderinfo.oordersource == "Sy.GameMoney") {
            this.$router.push({name: 'OrderMobileCoinDetailNew', query: {orderId: v.oid, count: v.orderinfo.oquantity}})
        }else {
          this.$messagebox({
            message: "骚年，常回电脑看看"
          });
        }
      }
    },
    whyClick(item) {
      let qq = item.serviceQQ;
      if (!qq) {
        this.$messagebox({
          message: `正在分配客服中，请稍后`
        });
      } else {
        this.$messagebox({
          message: `如点击联系客服无法启动QQ，请加客服QQ号(${qq})`
        });
      }
    },
    watchGoTop: function() {
      var vm = this;
      window.addEventListener("scroll", function() {
        vm.scrollTop =
          document.documentElement.scrollTop ||
          window.pageYOffset ||
          document.body.scrollTop;
      });
    },
    goToEquip(v) {
      if (v.orderinfo.otradingtype == 7) {
        var remark;
        if (v.orderinfo.oremarks) {
          remark = JSON.parse(v.orderinfo.oremarks);
        }
        if (
          v.orderstatus.oorderstatusid != 1 &&
          v.orderstatus.oorderstatusid != 2 &&
          v.orderstatus.oorderstatusid != 5
        ) {
          return;
        }
        if (remark.SubId) {
          window.location.href = `/member/member-seller-equipment-transaction.html?orderId=${v.oid}_${remark.SubId}`;
        } else {
          window.location.href = `/member/member-seller-equipment-transaction.html?orderId=${v.oid}_${v
            .mjsondata.SubId}`;
        }
      } else {
        this.$messagebox({
          message: "骚年，常回电脑看看"
        });
      }
    },
    goCustomer(val, url) {
      if (Object.keys(val).length) {
            if (val.DefaultIM==1 || (val.DefaultIM==2 && val.WYCustomService) || (val.DefaultIM==2 && !val.WYCustomService && val.IsOpenHX)) {
                location.href=`/member/huanxin1.html?url=${encodeURIComponent(url)}`
            } else {
                if(/baidu/i.test(navigator.userAgent.toLowerCase())||/MicroMessenger/i.test(navigator.userAgent.toLowerCase())){
                    this.$messagebox({
                        message: "如点击联系客服无法启动QQ，请加客服QQ号("+val.CustomServiceQQ+")"
                    })
                }else {
                    window.location.assign('mqqwpa://im/chat?chat_type=wpa&uin=' + val.CustomServiceQQ + '&version=1&src_type=web&web_src=oicqzone.com')
                }
            }
        }
    },
    getKefu(item) {
      var self = this;
      var orderinfo = item.orderinfo;
      if (orderinfo.otradingtype == 7) {
        if (orderinfo.oordersource == "M.MobileGameMoney") {
          var obj = JSON.parse(orderinfo.oopJsondata);
          window.location.assign(
            "mqqwpa://im/chat?chat_type=wpa&uin=" +
              obj.KefuQQ +
              "&version=1&src_type=web&web_src=oicqzone.com"
          );
        } else {
          this.getService(item.oid);
        }
      } else if (orderinfo.otradingtype == 10||orderinfo.otradingtype == 6) {
        this.getPcService(item.oid, parseInt(orderinfo.otradingtype));
 
      } else {
        this.getPcService(item.oid, parseInt(orderinfo.otradingtype));
      }
    },
    //主站商品联系客服（主站未开启环信暂用版本）
    getPcService(Id, ServiceType) {
      //账号5 寄售2 担保1
      let url = "";
      switch (ServiceType) {
          case 10:
						url = this.scPath
						break;
					case 6:
						url = this.scPath
						break;
					case 5:
						url = this.zhPath
						break;
					case 2:
						url = this.jsPath
						break;
					case 3:
						url = this.syPath
						break;
					case 1:
						url = this.dbPath
						break;
        default:
      }
      let urlpath = this.$concatUrl(
        {
          orderid: Id,
          usertype: 0,
          tradingtype: ServiceType,
          callback: "callback"
        },
        url
      );

      BuyerCenterApi.getOrderIm(urlpath).then(res => {
        if (res.data) {
          if (res.data.Order) {
            this.goCustomer(res.data.Order, urlpath);
          } else {
            //							this.$toast({ message: '联系客服失败，请稍后重试' })
							NTKF.im_openInPageChat('bq_1000_1472795888825');
          }
        }
      });
    },
    //M站商品联系客服
    getService(orderId) {
      let url = this.$concatUrl(
        { orderId, userType: 0, callback: "callback" },
        this.url
      );
      BuyerCenterApi.getOrderIm(url).then(res => {
        
        if (res.data) {
          if (res.data.Order) {
              this.goCustomer(res.data.Order, url);
          } else {
            this.$toast({ message: "联系客服失败，请稍后重试" });
          }
        }
      });
    },
    contactCustom(item, id) {
      let url = this.$concatUrl(
        { orderId: item, userType: 0, callback: "callback" },
        this.url
      );
      api.BuyerCenterApi.getOrderIm(url).then(res => {
        if (res.data) {
          if (res.data.Order) {
            if (res.data.Order.DefaultIM == 2) {
              //本地用户
              //this.$setCookie('uid', 'ldq')
              //this.$setCookie('sdktoken', '8f418dfb7c2c7a90c8a200729174919d')
              let userType = res.data.Order.UserType == 0 ? "buyer" : "seller";
              let obj = {
                userType: userType,
                orderInfo: res.data.Order
              };
              if (this.$isLocalStorageSupported()) {
                localStorage.setItem("imOrderInfo", JSON.stringify(obj));
              }
              //this.$store.dispatch('saveOrderInfo',obj);
              config.appkey = res.data.WYIM.AppKey;
              this.$setCookie("appkey", res.data.WYIM.AppKey, "/");
              if (config.appkey) {
                this.$setCookie("uid", res.data.WYIM.UserAccount, "/");
                this.$setCookie("sdktoken", res.data.WYIM.AccessToken, "/");
                //接口客服用户
                this.$router.push({
                  name: "chat",
                  params: {
                    //sessionId:'p2p-pcq',
                    sessionId: `p2p-${res.data.Order.WYCustomService.replace(
                      "@5173.com",
                      "%"
                    )}`,
                    orderInfo: "mobgoods-" + item,
                    id: id
                  }
                });
              }
            } else {
              this.goCustomer(res.data.Order, url);
            }
          }
        }
      });
    },
    saveSrollTop: function() {
      let vm = this;
      let params = {
        scrollTop: vm.scrollTop,
        status: vm.params.status
      };

      vm.setState(params);
    },
    initParams() {
      this.params.pageindex = 1;
      this.orderList = [];
      this.orderListAllLoad = false;
      //                this.clearMobilelist();
    },
    selectStatus: async function(val) {
      let vm = this;
      vm.$router.replace({
        // 伪跳转，改变链接但不会初始化数据
        path: "/vue/memberseller/SellerOrderCenter",
        query: {
          operator: vm.$route.query.operator,
          orderstatus: val
        }
      });
      vm.params.orderstatus = val;
      //设置为初始值
      vm.initParams();
      vm.getList();
    },
    async getList() {
      var self = this;
      self.loading = true;

      BuyerCenterApi.getOrderList(self.params).then(res => {
        if (res.data.Code == 200) {
          if (res.data.Data.OrderPages.Orders.length == 0) {
            self.orderListAllLoad = true;
          } else {
            for (var i = 0; i < res.data.Data.OrderPages.Orders.length; i++) {
              self.orderList.push(res.data.Data.OrderPages.Orders[i]);
            }
          }
        } else {
          self.$toast(res.data.Message);
        }

        self.loading = false;
      });
    },
    ...mapActions({
      getOrderMobileList: "member/MEMBER_SELLER_ORDER_MOBILE_LIST",
      clearMobilelist: "member/MEMBER_SELLER_ORDER_MOBILE_CLEAR_LIST",
      setState: "member/MEMBER_SELLER_ORDER_MOBILE_STATE"
    })
  },
  filters: {
    getGoodsTypeText(val) {
      return val == 1 ? "游戏装备" : val == 2 ? "游戏帐号" : val == 3 ? "游戏币" : "游戏帐号";
    },
    format: function(val) {
      return moment(val).format("YYYY-MM-DD HH:mm:ss");
    },
    getStatusText: function(val) {
      let text = "";

      switch (val) {
        case "1":
          text = "待发货";
          break;
        case "2":
          text = "待发货";
          break;
        case 3:
          text = "已发货";
          break;
        case 4:
          text = "交易完成";
          break;
        case 5:
          text = "已退款";
          break;
        case 6:
          text = "已取消";
          break;
        case 7:
          text = "退款中";
          break;
        case 8:
          text = "已付款";
          break;
        case 9:
          text = "申请退款中";
          break;
        case 10:
          text = "客服介入";
          break;
      }
      return text;
    },
    complainResultFilter,
    cancelReasonFilter
  }
};
</script>
<style src="css/common/member-cxy.css" ></style>

<style  scoped>
.fixedFill-mx {
  width: 100%;
  height: 0.96rem;
}

.loading {
  text-align: left;
  text-indent: 0.6rem;
  line-height: 0.5rem;
  height: 0.5rem;
  background: url("~images/loading.gif") left center no-repeat;
  background-size: 0.5rem;
  margin-top: -0.1rem;
  margin-left: 2.5rem;
}

/*  .sellnage-nav{
              position: fixed;
      width: 100%;
      z-index: 99;
      }*/
</style>
